package source

import (
	"net/http"

	"github.com/gin-gonic/gin"
	"go.mongodb.org/mongo-driver/mongo"
	"gorm.io/gorm"
)

// Handler 任务处理器
type Handler struct {
}

// NewHandler 创建任务处理器
func NewHandler(db *gorm.DB, mongoClient *mongo.Collection) *Handler {
	return &Handler{}
}

// RegisterRoutes 注册路由
func (h *Handler) RegisterRoutes(r *gin.RouterGroup) {
	sources := r.Group("/sources")
	{
		sources.POST("/", h.Create)
		sources.GET("/:id", h.Get)
		sources.GET("/", h.List)
		sources.PUT("/:id", h.Update)
		sources.DELETE("/:id", h.Delete)
	}
}

// Create 创建数据源
func (h *Handler) Create(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{"message": "Source created"})
}

// Get 获取数据源详情
func (h *Handler) Get(c *gin.Context) {
	id := c.Param("id")
	c.JSON(http.StatusOK, gin.H{"id": id, "message": "Source details"})
}

// List 获取数据源列表
func (h *Handler) List(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{"message": "Source list"})
}

// Update 更新数据源
func (h *Handler) Update(c *gin.Context) {
	id := c.Param("id")
	c.JSON(http.StatusOK, gin.H{"id": id, "message": "Source updated"})
}

// Delete 删除数据源
func (h *Handler) Delete(c *gin.Context) {
	id := c.Param("id")
	c.JSON(http.StatusOK, gin.H{"id": id, "message": "Source deleted"})
}
